package com.xxxxx.Servlet;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/* 乱码原因:
 * 	 由于在解析过程中默认使用的编码方式为ISO-8859-1(此编码不支持中文),所以解析时一定会出现乱码、
 * 
 * 请求乱码问题
 * 		GET请求: 不会乱码
 * 		POST请求: 会乱码,通过设置服务器解析编码的格式
 * 				request.setCharacterEncoding("utf-8");
 */


@WebServlet("/S5")
public class TestServlet05 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//设置请求的编码格式
		request.setCharacterEncoding("utf-8");
		
		//获取传递过来的uname
		String uname = request.getParameter("uname");
		//获取传递过来的upwd
		String upwd = request.getParameter("upwd");
		
		System.out.println("姓名: "+ uname);
		System.out.println("密码: "+ upwd);
	}
		
}
